package com.mt.roll.wms.dispatch;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.dal.entity.LocationStorageSub;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.dispatch.service.MachineHandService;
import com.mt.roll.wms.params.*;

import com.mt.roll.wms.service.AreaLocationService;
import com.mt.roll.wms.service.AreaService;
import com.mt.roll.wms.service.AreaShelfService;
import com.mt.roll.wms.vo.AreaLocationVo;
import com.mt.roll.wms.vo.AreaShelfVo;
import com.mt.roll.wms.vo.AreaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.groups.Default;
import java.util.List;

/**
 * @auther ylc
 * @date 2022/3/17 22:22
 */

@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "dispatch")
@Slf4j
@Api(value = "业务操作", tags = "业务操作", hidden = false)

public class LocalDispatchController extends BaseController {

    @Autowired
    private LocalDisPatchService localDisPatchService;

    @Autowired
    private MachineHandService machineHandService;

    @PostMapping(value = "empty")
    @ApiOperation(value = "工序位为空")
    private Integer locationEmpty( IdParam idParam,@RequestBody List<LocationStorageSub> subList){
        return localDisPatchService.locationEmpty(idParam, subList);
    }

    @PostMapping(value = "full")
    @ApiOperation(value = "工序位放满")
    private Integer locationFull( IdParam idParam,@RequestBody List<LocationStorageSub> subList){

        return localDisPatchService.locationFull(idParam, subList);
    }

    @PostMapping(value = "first")
    @ApiOperation(value = "进入第一个工序")
    private Integer sendSubToFirstProcess(IdParam idParam){
        return localDisPatchService.sendSubToFirstProcess(idParam);
    }

    //1 代表监听不同的机械手
    @PostMapping(value = "machineHandListener")
    @ApiOperation(value = "机械手 监听开始")
    private Boolean machineHandListener(Integer number){
        if(number==1){
            return machineHandService.machineHand1Task();
        }
        return false;
    }
}